import util from '../../utils/util';

const app = getApp()

Page({
  data: {
    isLoad:true,
    token:wx.getStorageSync("token"),
	userType:wx.getStorageSync("userType"),//用户类型：teacher|student
    timer:0,
	swiperList: [{
	  id: 0,
	  type: 'image',
	  url: 'https://mmbiz.qpic.cn/sz_mmbiz_png/ZS19FjAYCNdmT3UV73t9dm5WNIImQOMceeCQsrmmt4eyI05EEEy1Xfzaianu4piaMDc0icicVI6bpsMvLyDDe2dKog/640?wx_fmt=png&from=appmsg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1'
	}, {
	  id: 1,
	    type: 'image',
	    url: 'https://mmbiz.qpic.cn/sz_mmbiz_png/ZS19FjAYCNeOxsC9zye3mAcia8zhTPeDna6OCPzXlCHcdrJxlmv0yQIXicyQ9TpzMFP87par8qicjicjWgQS9VQvAw/640?wx_fmt=png&from=appmsg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1',
	}, {
	  id: 2,
	  type: 'image',
	  url: 'https://mmbiz.qpic.cn/sz_mmbiz_png/ZS19FjAYCNeOxsC9zye3mAcia8zhTPeDn8iaDQeADrq4W5VnlaUvKcAE5ttJh0Z8lH5fHQOFDcibTiaZ8Q3LWwhOlQ/640?wx_fmt=png&from=appmsg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1'
	}],
	iconList: [{
	  icon: 'present',
	  color: 'red',
	  badge: 120,
	  name: '请假'
	}, {
	  icon: 'activity',
	  color: 'orange',
	  badge: 1,
	  name: '活动报名'
	}, {
	  icon: 'vipcard',
	  color: 'yellow',
	  badge: 0,
	  name: '课表'
	}, {
	  icon: 'noticefill',
	  color: 'olive',
	  badge: 22,
	  name: '通知'
	}, {
	  icon: 'clothesfill',
	  color: 'cyan',
	  badge: 0,
	  name: '失物招领'
	}, {
	  icon: 'squarecheck',
	  color: 'blue',
	  badge: 0,
	  name: '选课'
	}, {
	  icon: 'rankfill',
	  color: 'purple',
	  badge: 0,
	  name: '投票'
	}, {
	  icon: 'questionfill',
	  color: 'mauve',
	  badge: 0,
	  name: '帮助'
	}]
  },

    onLoad() {
		var that = this;
		// that.isFastTime();//检查登录
		that.getNoticelist();
		
    },
	
	getNoticelist(){
		var that = this;
		const pageNum = 1;
		const pageSize = 2;
		const orderBy = 'create_time desc';
		util.get(`loadNotice?pageNum=${pageNum}&pageSize=${pageSize}&orderBy=${orderBy}`,response=>{
		  // TIPS: 为0不一般是失败么
		  if (response) {
		      that.setData({
				  messageData: response.data
			  });
		  }
		})
	},
	
    onShow(){
      var that = this;
	  console.log('usertype', wx.getStorageSync("userType"));
	  that.setData({
	      userType: wx.getStorageSync("userType")
	  });
	  const teacherinfo = wx.getStorageSync('teacheruserInfo');
	  const userinfo = wx.getStorageSync('userInfo');
	  const token = wx.getStorageSync('token');
      if (teacherinfo != null && teacherinfo != '') {
        // wx.navigateTo({
        //   url: 'teaindex/index',
        // })
		
	  } else if(userinfo != null && userinfo != ''&&token!='') {
		  // wx.navigateTo({
		  //   url: 'stuindex/index',
		  // })
	  }
    },
	noticeMore(){
		wx.navigateTo({
		  url:'notice/list/list'
		})
	},
	afterServiceMore(){
		wx.navigateTo({
		  url:'/pages/aftServ/index'
		})
	},
	leaveTeaMore(){
		wx.navigateTo({
		  url:'/pages/leaveTea/index'
		})
	}
   
})
